package com.linlang.grasharepro.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.linlang.grasharepro.R;
import com.linlang.grasharepro.adapter.SearchResultAdapter;
import com.linlang.grasharepro.dao.ShareCoentenDB;
import com.linlang.grasharepro.model.ShareCoenten;
import com.linlang.grasharepro.utils.ListViewUitls;

import java.util.ArrayList;

/**
 * Created by lixin on 2016-8-8.
 */
public class SearchResultActivity extends Activity {

    private ListView lv_mycollect;
    private ArrayList<ShareCoenten> collect_list = new ArrayList<ShareCoenten>();
    private ShareCoentenDB shareCoentenDB;
    private String searchContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        // 获取从列表当中传递过来的数据
        Intent intent = getIntent();
        Bundle bund = intent.getExtras();
        searchContent = (String) bund.getSerializable("searchContent");
        initView();
    }

    private void initView() {

        shareCoentenDB = new ShareCoentenDB(this);
        shareCoentenDB.open();

        collect_list = shareCoentenDB.queryByWheres(searchContent);


        lv_mycollect = (ListView) findViewById(R.id.lv_mycollect);
        final SearchResultAdapter searchResultAdapter = new SearchResultAdapter(collect_list, this);
        lv_mycollect.setAdapter(searchResultAdapter);
        ListViewUitls.setListViewHeightBasedOnChildren(lv_mycollect);

        lv_mycollect.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {

            }
        });
    }
}
